package com.rqf.ls.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.rqf.ls.service.IRemindService;
import com.server.web.JSONSerielizer;
import com.server.web.OutputUtil;

/**
 * 提醒功能
 * @author ServerZhang
 * @date 2016年3月28日
 */
@Controller
@RequestMapping("remind")
public class RemindController {
	
	@Autowired
	private IRemindService remindService;

	 /**
	 * 用户未读回复条数
	 * @param request
	 * @param response
	 * @param phoneNo
	 * @author ServerZhang
	 * @date 2016年3月28日
	 */
	@RequestMapping("answerCount/{phoneNo}")
	public void answerCount(HttpServletRequest request, 
			HttpServletResponse response,@PathVariable String phoneNo){
		Integer reminCount = remindService.userRemind(phoneNo);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("reminCount", reminCount);
		String json = JSONSerielizer.toJson(map, null, null);
		OutputUtil.returnJsonp(request, response, json);
	}
	 /**
	 * 律师未读提问条数
	 * @param request
	 * @param response
	 * @param phoneNo
	 * @author ServerZhang
	 * @date 2016年3月28日
	 */
	@RequestMapping("questionCount/{phoneNo}")
	public void questionCount(HttpServletRequest request, 
			HttpServletResponse response,@PathVariable String phoneNo){
		Integer reminCount = remindService.lawyerRemind(phoneNo);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("reminCount", reminCount);
		String json = JSONSerielizer.toJson(map, null, null);
		OutputUtil.returnJsonp(request, response, json);
	}
	
}
